
if (Ext) {
    Ext.BLANK_IMAGE_URL = 'scripts/ext/resources/images/default/s.gif'
}
var getPrarmeterValue = function(url, paraName){
    url += '';
    if (url.indexOf('?') == -1) {
        return null;
    }
    var subUrl = url.substring(url.indexOf('?') + 1);
    var parameterPairs = subUrl.split('&');
    for (var i = 0; i < parameterPairs.length; i++) {
        var index = parameterPairs[i].indexOf(paraName + '=');
        if (index != -1) {
            var length = (paraName + '=').length;
            return parameterPairs[i].substring(index + length);
        }
    }
    return null;
}

var deleteId;
var editId;
var deleteItem = function(deleteCallback, id){
    deleteId = id;
    Ext.MessageBox.confirm('Confirm', 'Do you want to delete the selected item?', deleteCallback);
}
var editItem = function(editCallback, id){
    editId = id;
    editCallback();
}

var messageTip = function(){
    var msgCt;
    
    function createBox(t, s){
        return ['<div class="msg">', '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>', '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>', '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>', '</div>'].join('');
    }
    return {
        msg: function(title, format){
            if (!msgCt) {
                msgCt = Ext.DomHelper.insertFirst(document.body, {
                    id: 'msg-div'
                }, true);
            }
            msgCt.alignTo(document, 't-t');
            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            var m = Ext.DomHelper.append(msgCt, {
                html: createBox(title, s)
            }, true);
            m.slideIn('t').pause(5).ghost("t", {
                remove: true
            });
        },
        
        init: function(){
        
        }
    };
}
();

var eurMoney = function(v){
    v = (Math.round((v - 0) * 100)) / 100;
    v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
    v = String(v);
    var ps = v.split(".");
    var whole = ps[0];
    var sub = ps[1] ? "." + ps[1] : ".00";
    var r = /(\d+)(\d{3})/;
    while (r.test(whole)) {
        whole = whole.replace(r, "$1" + "," + "$2")
    }
    v = whole + sub;
    if (v.charAt(0) == "-") {
        return v.substr(1) + "&nbsp;-€&nbsp;"
    }
    return v + "&nbsp;€&nbsp;";
}

Ext.onReady(messageTip.init, messageTip);

if (Ext.grid.GridFilters) {
    Ext.grid.GridFilters.menuText = 'Filters';
}
